//
//  WKNavgationController.m
//  WeKeTang
//
//  Created by ichina on 2017/8/22.
//  Copyright © 2017年 Dezhi Tiancheng Education Technology (Beijing) Co. Ltd. All rights reserved.
//

#import "WKNavgationController.h"
#import "WKBaseViewController.h"
#import "UIImage+Addition.h"
#import "NSString+Addition.h"

@interface WKNavgationController ()

@end

@implementation WKNavgationController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
}
- (void)setupUI{
    
   self.navigationBar.hidden = YES;

}
///设置是否允许自动旋转
- (BOOL)shouldAutorotate {
    return YES;
}
//支持的方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return [self.topViewController supportedInterfaceOrientations];
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    // 返回你所需要的状态栏样式
    return UIStatusBarStyleLightContent;
}
//重写push方法
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    
    if (self.childViewControllers.count > 0) {
        // 隐藏底部工具栏
        viewController.hidesBottomBarWhenPushed = YES;
        
        if ([viewController isKindOfClass:[WKBaseViewController class]]) {
            
            WKBaseViewController *baseVC = (WKBaseViewController*)viewController;
            
            if (self.childViewControllers.count >= 1 ) {
                //给除了首页控制器之外 所有的再次推出的控制器添加返回按钮
                baseVC.navItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithImage:[[UIImage  imageNamed:@"icon_return"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
            }
        }
        __weak typeof(viewController)Weakself = viewController;
        
        self.interactivePopGestureRecognizer.delegate = (id)Weakself;
    }
    [super pushViewController:viewController animated:animated];
    
}

- (void)backClick{
    
    [self popViewControllerAnimated:YES];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
